<template>
  <div class="dashboard-container">
    <div class="index_left">
      <div class="company_info">
        <div class="avatar">
          <img :src="avatar" alt="">
          <div>
            <div>进思教育   <el-tag type="info"> 体验版</el-tag></div>
            <div>{{ name }}  | 进思教育-{{ userInfo.departmentName }}</div>
          </div>
        </div>
        <div class="tojing">
          <div>
            <h2>组织人数</h2>
            <h2>633</h2>
          </div>
          <div>
            <h2>正式员工</h2>
            <h2>{{ homeData.contractSignTotal }}</h2>
          </div>
          <div>
            <h2>合同待签署</h2>
            <h2>{{ homeData.regularEmployeeTotal }}</h2>
          </div>
          <div>
            <h2>待入职</h2>
            <h2>{{ homeData.toBeEmployed }}</h2>
          </div>
          <div>
            <h2>本月待转正</h2>
            <h2>{{ homeData.toBeConfirmed }}</h2>
          </div>
          <div>
            <h2>本月待离职</h2>
            <h2>{{ homeData.toBeDismissed }}</h2>
          </div>
          <div>
            <h2>接口总访问</h2>
            <h2>{{ homeData.interfaceAccessTotal }}</h2>
          </div>
        </div>
      </div>
      <div class="quick_start">
        快捷入口
      </div>
      <div class="shebao">
        <!-- 社保模块 -->
        <charts-model :modelData="homeData.socialInsurance" />
      </div>
      <div class="pulick_money">
        <!-- 公积金模块 -->
        <charts-model :modelData="homeData.providentFund" />
      </div>
    </div>
    <div class="index_right">
      <div class="right_date">
          <index-date></index-date>
      </div>
      <div>
        <notice-com></notice-com>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { getHomeData } from '@/api/home'
// 图表组件
import chartsModel from './chartsModel.vue'
// 日期组件
import indexDate from './indexDate.vue'
// 通知公告
import noticeCom from './notice'
export default {
  name: 'Dashboard',
  components: { chartsModel,indexDate,noticeCom},
  data() {
    return {
      homeData: {}, // 首页数据
      userInfo: {}// 用户信息
    }
  },
  computed: {
    ...mapGetters([
      'name',
      'avatar'
    ])
  },
  created() {
    this.getData()
    // 接受navBar传来的用户信息数据
    this.$bus.$on('senduser', (val) => {
      this.userInfo = val
    })
  },
  methods: {
    async getData() { // 获取首页数据的接口
      const res = await getHomeData()
      console.log(res, '0000000000')
      this.homeData = res
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
.dashboard-container{
  width: 100vw;
  display: flex;
  .index_left{
    flex:1;
    .company_info{
      width: 100%;
      height: 278px;
      background: skyblue;
        .avatar{
          img{
            width: 100px;
            height: 80px;
            margin: 0 20px;
          }
          display: flex;
          align-items: center;
        }
        .tojing{
          display: flex;
          flex-wrap: wrap;
          >div{
            width: 200px;
            height: 80px;
            text-align: center;
            line-height: 40px;
            h2{
              font-size: 17px;
            }
          }
        }
    }
  }
  .index_right{
    width: 814px;
    margin-left: 20px;
    background: white;
    .right_date{
      height:350px;
      overflow: hidden;
      margin-bottom: 20px;
    }
  }
}

</style>
